# -*- coding: utf-8 -*-
# env: python 3
# fuction: 钉钉自定义机器人调用



import os
import requests
import time

def sendmsg(msg):

    url='https://oapi.dingtalk.com/robot/send?access_token=xxxxx' 
    headers={'Content-Type': 'application/json'}
    
    smsg="告警 xxxxx %s " %msg 
    senddata={
              "at":{ 
                    "isAtAll": "false"
                   },
              "text": {
                    "content": smsg
                    },
                "msgtype": "text"
              }
    # senddata='{"msgtype": "text","text": {"content":"a xxxx "}}' 

    # print(url)
    # print(senddata)
    # print(type(senddata))
    
    resp=requests.post(url,json=senddata,headers=headers)
    print(resp.text)

sendmsg("this is test  ")

